
<import type='css' file="Setting.Css.user-setting" />
<import type='js' file="Main.Js.compatibility" />
<div class="aw-container-wrap">
	<div class="container">
		<div class="row">
			<div class="aw-content-wrap clearfix">
				<div class="aw-user-setting">
					<div class="tabbable">
						<ul class="nav nav-tabs aw-nav-tabs active">
							<li><a href="{:U('Home/Setting/verify/')}">申请认证</a></li>
							<li class="active"><a href="{:U('Home/Setting/security/')}">安全设置</a></li>
							<li><a href="{:U('Home/Setting/upload/')}">头像上传</a></li>
							<li><a href="{:U('Home/Setting/people/')}">基本资料</a></li>
							
							<h2><i class="icon icon-setting"></i> 用户设置</h2>
						</ul>
					</div>
					
					<div class="tab-content clearfix">
<div class="aw-mod">
	<div class="mod-body">
		<div class="aw-mod aw-user-setting-bind">
			<div class="mod-head">
				<h3>修改密码</h3>
			</div>
			<form class="form-horizontal" action="__ROOT__/index.php/Home/Setting/security" method="post" id="setting_form">
				<div class="mod-body">
					<div id="password" style="position:relative;" class="form-group">
						<label class="control-label" for="input-password-old">当前密码</label>
						<div class="row">
							<div class="col-lg-4">
								<input class="form-control" id="input-password-old" name="old_password" type="password" value="">

							</div>
						</div>
					</div>
					<div class="form-group">
						<label class="control-label" for="input-password-new">新的密码</label>
						<div class="row">
							<div class="col-lg-4">
							    <input class="form-control" id="input-password-new" name="password" type="password">
							</div>
						</div>
					</div> 
					<div id="r_paw" class="form-group">
						<label class="control-label" for="input-password-re-new">确认密码</label>
						<div class="row">
							<div class="col-lg-4">
							    <input class="form-control" id="input-password-re-new" name="re_password" type="password"/>
							</div>
						</div>
					</div>      
				</div>
				<div class="mod-footer clearfix">
					<input type="submit" id="submit" disabled="disabled" class="btn btn-large btn-success pull-right" value="保存" />
				</div>
			</form>
		</div>
	</div>
	
</div>

<script type="text/javascript">
	
	$(function(){
		//
		var password = $('#input-password-old').val();

		var f_paw = $('#input-password-new').val();

		var r_paw = $('#input-password-re-new').val(); 

		$('#input-password-old').blur(function(){

			var url = "{:U('/Home/Setting/security_ajax')}";
			
			var password = $(this).val();
			$.post(url, {password: password}, function(data) {
				
				if (data == 1) {
					$('#password').append("<div id='div' class='yes' style=\"position:absolute;top:29px;left:282px;height:20px;width:20px;\"><img src=\"../../../Public/Main/Img/yes.png\"></div>");

					var f_paw = $('#input-password-new').val();
					var r_paw = $('#input-password-re-new').val();
					if(f_paw == r_paw && r_paw!=''){

						$('#submit').removeAttr('disabled');
					}

				}else if(data ==2){
					
					$('#password').append("<div id='div' class='no' style=\"height:18px;width:400px;margin-bottom:-12px;color:#BA0000;\"><img style=\"margin-bottom:4px;\" src=\"../../../Public/Main/Img/no.png\">&nbsp;&nbsp;用户名或者邮箱不正确！</div>");
				}

			});

		})


		$('#input-password-old').focusin(function() {

			$('#submit').attr({disabled:'disabled'});
			$('#password').children('#div').remove();
		});

		$('#input-password-new').blur(function(event) {

			var length = $(this).val().length;
			if (length < 6 ) {
				alert('请输入至少6位的密码！');
				$('#input-password-re-new').attr({disabled:'disabled'});
			};

		})

		$('#input-password-re-new, #input-password-new').blur(function(){
			var f_paw = $('#input-password-new').val();

			var r_paw = $('#input-password-re-new').val();

			if(f_paw != r_paw && r_paw!=''){
				
				$('#r_paw').append("<div id='div' style=\"height:18px;width:400px;margin-bottom:-12px;color:#BA0000;\"><img style=\"margin-bottom:4px;\" src=\"../../../Public/Main/Img/no.png\">&nbsp;&nbsp;两次输入的新密码不一样，请认真检查！</div>");
				


			}else{
				$('#r_paw').find('#div').remove();
				var div = $('#password ').find('#div').attr("class");
				if(div == 'yes'){

					$('#submit').removeAttr('disabled');
				}
			}
			
		});
		$('#input-password-re-new, #input-password-new').focusin(function() {
			$('#submit').attr({disabled:'disabled'});
			$('#input-password-re-new').removeAttr('disabled');
			$('#r_paw').children('#div').remove();
		});		
	});	
</script>

					</div>
				</div>
			</div>
		</div>
	</div>
</div>